package com.container;

import java.util.List;



import com.activity.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class LibroAdapter extends BaseAdapter {

	private Context mContext;
	private List<Libro> elements;
	
	
	public LibroAdapter(Context mContext, List<Libro> elements) {
		this.mContext = mContext;
		this.elements = elements;
	}

	public int getCount() {
		return elements.size();
	}

	public Libro getItem(int position) {
		return elements.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Libro lib = elements.get(position);
		
		View v = View.inflate(mContext, R.layout.row_libro, null);

		TextView nom = (TextView) v.findViewById(R.id.libro_nombre);
		TextView aut = (TextView) v.findViewById(R.id.libro_autor);
		TextView prec = (TextView) v.findViewById(R.id.libro_precio);
		
		nom.setText(lib.getNombre());
		aut.setText("Autor: " + lib.getAutor());
		prec.setText("Precio: " + String.valueOf(lib.getPrecio()));
		
		return v;
	}

}